from SessionEndTime import SessionEndTime
from Talk import Talk
from Session import Session
from TraceNode import TraceNode
from TraceNodeMaker import TraceNodeMaker


class Conference:
    __morningSession: Session
    __afternoonSession: Session
    __talks: list

    @property
    def morningSession(self):
        return self.__morningSession

    @property
    def afternoonSession(self):
        return self.__afternoonSession

    @property
    def talks(self):
        return self.__talks

    def __init__(self, m_session, af_session, talks: [Talk]):
        self.__morningSession = m_session
        self.__afternoonSession = af_session
        self.__talks = talks

    def printAllTracks(self)->list:
        m_maker = TraceNodeMaker(self.morningSession.maxDuration, self.morningSession.minDuration, self.talks)
        tracks = []
        for m_node in m_maker.traceNodes:
            other_talks = list(set(self.talks) - set(m_node.talks))
            af_maker = TraceNodeMaker(self.afternoonSession.maxDuration, self.afternoonSession.minDuration, other_talks)
            for af_node in af_maker.traceNodes:
                print("Track %d:" % (len(tracks)+1))
                tracks.append([m_node, af_node])
                track = self.morningSession.printTalks(m_node.talks)
                track[-1] += "Lunch"
                print(track[-1])
                track += self.afternoonSession.printTalks(af_node.talks)
                track[-1] += "Networking Event"
                print(track[-1])
        return tracks

    def printTraceNodesCount(self)->int:
        m_maker = TraceNodeMaker(self.morningSession.maxDuration, self.morningSession.minDuration, self.talks)
        count = 0
        for m_node in m_maker.traceNodes:
            other_talks = list(set(self.talks) - set(m_node.talks))
            af_maker = TraceNodeMaker(self.afternoonSession.maxDuration, self.afternoonSession.minDuration, other_talks)
            count += len(af_maker.traceNodes)
        print(count)
        return count

    def print(self):
        self.printAllTracks()



